-
Notifications
You must be signed in to change notification settings - Fork 30
MVVM RxSwift Architechture #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mvc_architect
Are you sure you want to change the base?
Conversation
| switch result { | ||
| case .success(let response): | ||
| self?.navigator.toListUser(users: response?.users) | ||
| case .failure(_): break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty Enum Arguments Violation: Arguments can be omitted when matching enums with associated types if they are not used. (empty_enum_arguments)
| } | ||
|
|
||
| let inputRequest = Driver.combineLatest(input.keyword, input.limitNumber) { | ||
| (keyword, limitNumber) -> SearchRequest in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closure Parameter Position Violation: Closure parameters should be on the same line as opening brace. (closure_parameter_position)
| let navigator = DefaultSearchNavigator(navigationController: self.navigationController) | ||
| viewModel = SearchViewModel(userRepository: userRepository, navigator: navigator) | ||
|
|
||
| let input = SearchViewModel.Input(keyword: searchTextField.rx.text.orEmpty.asDriver(), limitNumber: limitNumberTextField.rx.text.orEmpty.asDriver(), searchTrigger: searchButton.rx.tap.asDriver()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 120 characters or less: currently 203 characters (line_length)
| func searchUsers(keyword: String, limit: Int, completion: @escaping (BaseResult<SearchResponse>) -> Void) { | ||
| let input = SearchRequest(keyword: keyword, limit: limit) | ||
|
|
||
| func searchUsers(input: SearchRequest, completion: @escaping (BaseResult<SearchResponse>) -> Void){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
| let activityIndicator = ActivityIndicator() | ||
|
|
||
| let canSearch = Driver.combineLatest(keywordAndLimitNumber, activityIndicator.asDriver()) | ||
| { (keywordAndLimitNumber, activityIndicator) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
| } | ||
|
|
||
| func asDriverOnErrorJustComplete() -> Driver<E> { | ||
| return asDriver { error in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused Closure Parameter Violation: Unused parameter "error" in a closure should be replaced with _. (unused_closure_parameter)
| completion(nil, BaseError.apiFailure(error: error)) | ||
|
|
||
| return Observable.create {observer in | ||
| self.alamofireManager.request(input.url, method: input.requestType, parameters: input.body, encoding: input.encoding) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 120 characters or less: currently 129 characters (line_length)
| } else { | ||
| completion(nil, BaseError.unexpectedError) | ||
| observer.on(.completed) | ||
| case .failure(_): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty Enum Arguments Violation: Arguments can be omitted when matching enums with associated types if they are not used. (empty_enum_arguments)
| import RxCocoa | ||
|
|
||
| public class ActivityIndicator: SharedSequenceConvertibleType { | ||
| public typealias E = Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type Name Violation: Type name should be between 3 and 40 characters long: 'E' (type_name)
| let activityIndicator = ActivityIndicator() | ||
|
|
||
| let canSearch = Driver.combineLatest(keywordAndLimitNumber, activityIndicator.asDriver()) | ||
| { (keywordAndLimitNumber, activityIndicator) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
| } | ||
|
|
||
| func asDriverOnErrorJustComplete() -> Driver<E> { | ||
| return asDriver { error in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused Closure Parameter Violation: Unused parameter "error" in a closure should be replaced with _. (unused_closure_parameter)
| completion(nil, BaseError.apiFailure(error: error)) | ||
|
|
||
| return Observable.create {observer in | ||
| self.alamofireManager.request(input.url, method: input.requestType, parameters: input.body, encoding: input.encoding) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 120 characters or less: currently 129 characters (line_length)
| } else { | ||
| completion(nil, BaseError.unexpectedError) | ||
| observer.on(.completed) | ||
| case .failure(_): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty Enum Arguments Violation: Arguments can be omitted when matching enums with associated types if they are not used. (empty_enum_arguments)
03db6a4 to
a7b97b8
Compare
a7b97b8 to
a4ecea4
Compare
a4ecea4 to
d6c3145
Compare
| }).mapToVoid() | ||
|
|
||
| return SearchViewModel.Output(searchButtonEnable: canSearch, errorInputNumber: errorInputNumber, | ||
| search: search, error: errorTracker.asDriver(), dissmiss: activityIndicator.asDriver()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 120 characters or less: currently 125 characters (line_length)
| } | ||
|
|
||
| var errorBinding: Binder<Error> { | ||
| return Binder(self, binding: { (vc, error) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'vc' (identifier_name)
| } | ||
| } | ||
| var errorInputNumberBinding: Binder<String> { | ||
| return Binder(self, binding: { (vc, errorText) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'vc' (identifier_name)
|
|
||
| /// Bindable sink for `show()`, `hide()` methods. | ||
| public static var isAnimating: Binder<Bool> { | ||
| return Binder(UIApplication.shared) { progressHUD, isVisible in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused Closure Parameter Violation: Unused parameter "progressHUD" in a closure should be replaced with _. (unused_closure_parameter)
| }).mapToVoid() | ||
|
|
||
| return SearchViewModel.Output(searchButtonEnable: canSearch, errorInputNumber: errorInputNumber, | ||
| search: search, error: errorTracker.asDriver(), dissmiss: activityIndicator.asDriver()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 120 characters or less: currently 125 characters (line_length)
| } | ||
|
|
||
| var errorBinding: Binder<Error> { | ||
| return Binder(self, binding: { (vc, error) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'vc' (identifier_name)
| } | ||
| } | ||
| var errorInputNumberBinding: Binder<String> { | ||
| return Binder(self, binding: { (vc, errorText) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'vc' (identifier_name)
|
|
||
| /// Bindable sink for `show()`, `hide()` methods. | ||
| public static var isAnimating: Binder<Bool> { | ||
| return Binder(UIApplication.shared) { progressHUD, isVisible in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused Closure Parameter Violation: Unused parameter "progressHUD" in a closure should be replaced with _. (unused_closure_parameter)
7f98926 to
776251c
Compare
| } | ||
| } | ||
| var errorBinding: Binder<Error> { | ||
| return Binder(self, binding: { (vc, error) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'vc' (identifier_name)
| } | ||
|
|
||
| var errorInputNumberBinding: Binder<String> { | ||
| return Binder(self, binding: { (vc, errorText) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'vc' (identifier_name)
| print(user) | ||
| } | ||
| let output = viewModel.transform(input: input) | ||
| output.users.drive(tableView.rx.items(cellIdentifier: ListUsersTableViewCell.reuseID, cellType: ListUsersTableViewCell.self)) { (_, viewModel, cell) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 120 characters or less: currently 159 characters (line_length)
|
|
||
| let userItemViewModels = Observable.just(self.users).asDriverOnErrorJustComplete() | ||
| .map { $0.map { UserItemViewModel(with: $0) }} | ||
| let selectedCell = input.selection.withLatestFrom(userItemViewModels) { (indexPath, userItemViewModels) -> User in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 120 characters or less: currently 122 characters (line_length)
776251c to
4418039
Compare
| let userItemViewModels = Observable.just(self.users).asDriverOnErrorJustComplete() | ||
| .map { $0.map { UserItemViewModel(with: $0) }} | ||
| let selectedCell = input.selection.withLatestFrom(userItemViewModels) | ||
| { (indexPath, userItemViewModels) -> User in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
5147a89 to
1a2c86c
Compare
| break | ||
| } | ||
| }, usingThreshold: UInt64.init(), to: input.url) { (result) in | ||
| switch result{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
| } | ||
| break | ||
| } | ||
| }, usingThreshold: UInt64.init(), to: input.url) { (result) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple Closures with Trailing Closure Violation: Trailing closure syntax should not be used when passing more than one closure argument. (multiple_closures_with_trailing_closure)
2db03db to
8fe33e7
Compare
| (cell as! ListUsersTableViewCell).bind(viewModel: element) | ||
| } else { | ||
| cell = tableView.dequeueReusableCell(withIdentifier: ListUsersTableViewCell.reuseID, for: indexPath) | ||
| (cell as! ListUsersTableViewCell).bind(viewModel: element) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force Cast Violation: Force casts should be avoided. (force_cast)
| var cell: UITableViewCell! | ||
| if indexPath.row == 1 { | ||
| cell = tableView.dequeueReusableCell(withIdentifier: ListUsersTableViewCell.reuseID, for: indexPath) | ||
| (cell as! ListUsersTableViewCell).bind(viewModel: element) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force Cast Violation: Force casts should be avoided. (force_cast)
8fe33e7 to
56673d7
Compare
CleanArchitectureMVVMRxSwift
base on: sergdort/CleanArchitectureRxSwift